﻿//------------------------------------------------------------------------------
// <copyright file="Stature.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using Microsoft.Internal.GamesTest.Rpc.Server;

namespace Rpc.CSharpSample
{
    /// <summary>
    /// Represents the Player appearance for testing RPC Server.
    /// </summary>
    public class Stature
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Stature"/> class.
        /// </summary>
        public Stature()
        {
        }

        /// <summary>
        /// Gets or sets the player height.
        /// </summary>
        public ushort Height
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the player weight.
        /// </summary>
        public ushort Weight
        {
            get;
            set;
        }

        /// <summary>
        /// Deserializes a Stature object from the archive.
        /// </summary>
        /// <param name="archive">Archive to read Stature from.</param>
        /// <returns>The stature object reconstructed from an archive.</returns>
        public static Stature FromRpcArchive(RpcArchive archive)
        {
            Stature stature = new Stature();
            stature.Height = archive.GetNamedWordValue("height");
            stature.Weight = archive.GetNamedWordValue("weight");

            return stature;
        }

        /// <summary>
        /// Serializes a Stature object to an archive.
        /// </summary>
        /// <returns>An archive containing the serialized Stature object.</returns>
        public RpcArchive ToRpcArchive()
        {
            RpcArchive archive = new RpcArchive();
            archive.SetNamedWordValue("height", this.Height);
            archive.SetNamedWordValue("weight", this.Weight);

            return archive;
        }
    }
}
